package com.hwadee.backend.service;

import com.hwadee.backend.entity.HealthRecord.HealthRecord;
import com.hwadee.backend.entity.log.Loggy;
import com.hwadee.backend.mapper.LoggyMapper;
import com.hwadee.backend.mapper.HealthRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogService {
    @Autowired
    private LoggyMapper loggyMapper;
    // 添加 HealthRecordMapper 注入
    @Autowired
    private HealthRecordMapper healthRecordMapper;

    public List<Loggy> getLogs() {
        // 使用 MyBatis-Plus 内置的 selectList 方法查询所有记录
        return loggyMapper.selectList(null);
    }

    public HealthRecord getHealthRecord(int recordId) {
        return healthRecordMapper.selectById(recordId);
    }

    public void addLog(Loggy loggy) {
        loggyMapper.insert(loggy);
    }

    public void deleteLog(int logId) {
        // 调用 LoggyMapper 进行删除操作
        loggyMapper.deleteById(logId);
    }
}
